from sklearn.datasets import load_iris
from sklearn.model_selection import train_test_split
from sklearn.linear_model import LogisticRegression
from sklearn.metrics import accuracy_score
import numpy as np

#1.加载数据
X,y = load_iris(return_X_y=True)     #快速获得参数
print(np.shape(X),np.shape(y))
X_train,X_test,y_train,y_test = train_test_split (X,y,test_size = 0.15)

#2.指定分类模型
lr = LogisticRegression(max_iter=1000)

#3.训练模型
lr.fit(X_train,y_train)

#4.评估模型    metrics 什么问题用什么指标评估（acc准确率、precision精确率、recall召回率、f1）
x = accuracy_score(y_test,lr.predict(X_test))
print(x)


#5.预测模型